﻿using DoNet.Core;
using DoNet.Core.UnitOfWork;
using DoNet.System.IRepositories;
using DoNet.System.Models;

namespace DoNet.System.Repositories
{
    /// <summary>
    /// 应用仓储实现
    /// </summary>
    public class AppRepository : BaseRepository<App>, IAppRepository
    {
        public AppRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {
        }

        /// <summary>
        /// 获取app对象
        /// </summary>
        /// <param name="appid">应用ID</param>
        /// <param name="secret">应用密钥AppSecret</param>
        /// <returns></returns>
        public App GetAPP(string appid, string secret)
        {
            return Db.Queryable<App>().First(t => t.AppId == appid && t.AppSecret == secret && t.EnabledMark == true);
        }

        /// <summary>
        /// 获取app对象
        /// </summary>
        /// <param name="appid">应用ID</param>
        /// <returns></returns>
        public App GetAPP(string appid)
        {
            return Db.Queryable<App>().First(t => t.AppId == appid);

        }
    }
}
